package com.googlecode.skald.client.cmds;

import com.googlecode.skald.client.GUI;
import com.googlecode.skald.client.Server;
import com.googlecode.skald.client.Skald;

/**
 * As SendCmd, but also updates the GUI to show that a command has been sent.
 * 
 * @see GUI#displayInput(String)
 * 
 * @author Zach Tomaszewski
 */
public class DisplayedSendCmd extends SendCmd {

  public DisplayedSendCmd(String cmdText) {
    super(cmdText);
  }
  
  /**
   * Calls {@link Server#sendCmd} with this SendCmd's text.
   */
  @Override
  public void execute() {
    super.execute();
    //XXX: would rather have menu-path display text here, but requires major
    // redesign of affordances' TrieNode and and cmd's builder architecture
    Skald.getGui().displayInput(this.getCmd());   
  }

  /** Any SendCmd can also act as a builder for more (different) SendCmds. */
  @Override
  public AffordanceCommand build(String cmdText) {    
    return new DisplayedSendCmd(cmdText);
  }
}
